﻿namespace EFS.RC.CommunicatorContext.Common.Config
{
	public static class Main
	{
		// tracing
		public static System.Boolean Tracing { get; private set; }

		/// ShowQuestionnaire
		public static System.Boolean ShowQuestionnaire { get; private set; }

		/// SurveyUrlScheme
		public static System.String SurveyUrlScheme { get; private set; }

		/// SurveyUrlHost
		public static System.String SurveyUrlHost { get; private set; }

		/// SurveyUrlPort
		public static System.Int32? SurveyUrlPort { get; private set; }

		/// RequestConversationHandoverForSurveyMessage
		public static System.String RequestConversationHandoverForSurveyMessage { get; private set; }

		public static void Init(
			System.Windows.StartupEventArgs e)
		{
			// tracing
			Tracing = e.InitParams.Keys.Contains("Tracing") ? "true" == e.InitParams["Tracing"].ToLower() : false;

			// show survey
			ShowQuestionnaire = true;
			if (e.InitParams.ContainsKey("ShowQuestionnaire"))
			{
				System.Boolean showQuestionnaire = true;
				if (System.Boolean.TryParse(e.InitParams["ShowQuestionnaire"], out showQuestionnaire))
				{
					ShowQuestionnaire = showQuestionnaire;
				}
			}

			// survey
			SurveyUrlScheme = e.InitParams["SurveyUrlScheme"];
			SurveyUrlHost = e.InitParams["SurveyUrlHost"];
			SurveyUrlPort = null;
			if (e.InitParams.ContainsKey("SurveyUrlPort"))
			{
				System.Int32 surveyUrlPort = 0;
				if (System.Int32.TryParse(e.InitParams["SurveyUrlPort"], out surveyUrlPort))
				{
					SurveyUrlPort = surveyUrlPort;
				}
			}

			// customer survey
			RequestConversationHandoverForSurveyMessage = e.InitParams["RequestConversationHandoverForSurveyMessage"];
		}
	}

}